import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ShopRoleVO, ShopRoleForm, ShopRoleQuery } from '@/api/system/shopRole/types';
import { MenuTreeOption } from './types';

/**
 * 查询店铺角色列表
 * @param query
 * @returns {*}
 */

export const listShopRole = (query?: ShopRoleQuery): AxiosPromise<ShopRoleVO[]> => {
  return request({
    url: '/system/shopRole/queryShopRolePage',
    method: 'get',
    params: query
  });
};

/**
 * 查询店铺角色详细
 * @param id
 */
export const getShopRole = (id: string | number): AxiosPromise<ShopRoleVO> => {
  return request({
    url: '/system/shopRole/queryShopRoleInfo/' + id,
    method: 'get'
  });
};

/**
 * 新增店铺角色
 * @param data
 */
export const addShopRole = (data: ShopRoleForm) => {
  return request({
    url: '/system/shopRole/addShopRole',
    method: 'post',
    data: data
  });
};

/**
 * 修改店铺角色
 * @param data
 */
export const updateShopRole = (data: ShopRoleForm) => {
  return request({
    url: '/system/shopRole/updateShopRole',
    method: 'post',
    data: data
  });
};

/**
 * 删除店铺角色
 * @param id
 */
export const delShopRole = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/shopRole/deleteShopRole/' + id,
    method: 'delete'
  });
};

/**
 * 查询店铺所有角色
 */
export const queryShopRoleList = () => {
  return request({
    url: '/system/shopRole/queryShopRoleList',
    method: 'get'
  });
};

/**
 * 查询菜单树状列表
 */
export const treeselect = (): AxiosPromise<MenuTreeOption[]> => {
  return request({
    url: '/system/shopRole/queryOperabilityShopMenuVoList',
    method: 'get'
  });
};
